package define;

public enum AttributeType 
{
	E_LENGTH_ATTR("len"),
	E_UP_FIRST_ATTR("up 1st"),
	E_LOW_FIRST_ATTR("low 1st"),
	E_TO_UP_ATTR("2up"),
	E_TO_LOW_ATTR("2low"),
	E_LAST_ATTR("last"),
	E_SIZE_ATTR("size"),
	E_COUNT_ATTR("count"),
	E_GET_ATTR("get"),
	E_SPLIT_ATTR(""),
	;
	
	private String m_keyword;
	
	private AttributeType(String keyword)
	{
		m_keyword = keyword;
	}
	
	public String getKeyword()
	{
		return m_keyword;
	}
	
	public static AttributeType hasAttribute(String attr)
	{
		attr = attr.toLowerCase();
		for(int i = 0, max = E_COUNT_ATTR.ordinal(); i < max; ++i)
		{
			if(attr.compareTo(AttributeType.values()[i].getKeyword()) == 0)
			{
				return AttributeType.values()[i];
			}
		}
		return null;
	}
	
	public static AttributeType isSplitAttribute(String attr)
	{
		attr = attr.toLowerCase();
		for(int i = E_COUNT_ATTR.ordinal(), max = E_SPLIT_ATTR.ordinal(); i < max; ++i)
		{
			if(attr.compareTo(AttributeType.values()[i].getKeyword()) == 0)
			{
				return AttributeType.values()[i];
			}
		}
		return null;
	}
}
